/**
 * Copyright (c) iwindplus Technologies Co., Ltd.2024-2030, All rights reserved.
 */

package com.iwindplus.gateway.server.domain.constant;

import com.iwindplus.base.domain.constant.CommonConstant;
import org.springframework.core.Ordered;

/**
 * 常数.
 *
 * @author zengdegui
 * @since 2020/11/8
 */
public class GatewayConstant {

    private GatewayConstant() {
        throw new IllegalStateException(CommonConstant.UTILITY_CLASS);
    }

    /**
     * RING缓存相关常数 .
     */
    public static final int RING_BUFFER_SIZE = 1 << 14;

    /**
     * URL常数 .
     */
    public static class UrlConstant {

        private UrlConstant() {
            throw new IllegalStateException(CommonConstant.UTILITY_CLASS);
        }

        /**
         * 登出URL .
         */
        public static final String LOGOUT_URL = "/oauth2/logout";
    }

    /**
     * filter顺序相关常数（注意：顺序有讲究，可能存在依赖关系） .
     */
    public static class FilterConstant {

        private FilterConstant() {
            throw new IllegalStateException(CommonConstant.UTILITY_CLASS);
        }

        /**
         * 请求体过滤器顺序.
         */
        public static final Integer FILTER_REQUEST_BODY_ORDER = Ordered.HIGHEST_PRECEDENCE + 5;

        /**
         * 基础过滤器顺序.
         */
        public static final Integer FILTER_BASE_ORDER = Ordered.HIGHEST_PRECEDENCE + 10;

        /**
         * API签名过滤器顺序.
         */
        public static final Integer FILTER_API_SIGN_ORDER = Ordered.HIGHEST_PRECEDENCE + 15;

        /**
         * IP黑名单过滤器顺序.
         */
        public static final Integer FILTER_IP_BLACK_LIST_ORDER = Ordered.HIGHEST_PRECEDENCE + 20;

        /**
         * API白名单过滤器顺序.
         */
        public static final Integer FILTER_API_WHITE_LIST_ORDER = Ordered.HIGHEST_PRECEDENCE + 25;

        /**
         * 认证过滤器顺序.
         */
        public static final Integer FILTER_AUTH_ORDER = Ordered.HIGHEST_PRECEDENCE + 30;

        /**
         * 日志过滤器顺序.
         */
        public static final Integer FILTER_LOG_ORDER = Ordered.HIGHEST_PRECEDENCE + 35;
    }

    /**
     * 上下文相关常数 .
     */
    public static class ServerWebExchangeContextConstant {

        private ServerWebExchangeContextConstant() {
            throw new IllegalStateException(CommonConstant.UTILITY_CLASS);
        }

        /**
         * 请求时间.
         */
        public static final String REQUEST_TIME = "requestTime";

        /**
         * 白名单标记.
         */
        public static final String WHITED_FLAG = "whitedFlag";

        /**
         * 用户信息.
         */
        public static final String USER_INFO = "userInfo";
    }
}
